package org.millioncall.yueyoga.admin.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.millioncall.openplatform.common.PaginatedList;
import org.millioncall.openplatform.util.NumberUtils;
import org.millioncall.openplatform.util.WebAppUtils;
import org.millioncall.yueyoga.admin.model.GoodType;
import org.millioncall.yueyoga.admin.model.Goods;
import org.millioncall.yueyoga.admin.model.GoodsOrderDetail;
import org.millioncall.yueyoga.admin.model.Group;
import org.millioncall.yueyoga.admin.model.GroupUserModel;
import org.millioncall.yueyoga.admin.model.Member;
import org.millioncall.yueyoga.admin.model.Order;
import org.millioncall.yueyoga.admin.model.OrderDetail;
import org.millioncall.yueyoga.admin.model.Product;
import org.millioncall.yueyoga.admin.model.ProductRemaining;
import org.millioncall.yueyoga.admin.model.Remaining;
import org.millioncall.yueyoga.admin.model.Site;
import org.millioncall.yueyoga.admin.model.Status;
import org.millioncall.yueyoga.admin.model.User;
import org.millioncall.yueyoga.admin.service.GoodTypeService;
import org.millioncall.yueyoga.admin.service.GoodsOrderDetailService;
import org.millioncall.yueyoga.admin.service.GoodsService;
import org.millioncall.yueyoga.admin.service.MemberClazzService;
import org.millioncall.yueyoga.admin.service.MemberService;
import org.millioncall.yueyoga.admin.service.OrderDetailService;
import org.millioncall.yueyoga.admin.service.OrderService;
import org.millioncall.yueyoga.admin.service.ProductRemainingService;
import org.millioncall.yueyoga.admin.service.ProductService;
import org.millioncall.yueyoga.admin.service.RemainingService;
import org.millioncall.yueyoga.admin.service.SystemService;
import org.millioncall.yueyoga.admin.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class OrderAction extends BaseAction {
	private GoodsService goodservive;
	private OrderService orderService;
	private MemberClazzService memberClazzService;
	private GoodsOrderDetailService goodsOrderDetailService;
	private UserService userService;
	private GoodTypeService goodTypeService;
	private RemainingService remainingService;
	private ProductRemainingService productRemainingService;

	/** 添加账单 */
	@RequestMapping(value = "/ajaxaddorder.do")
	public void addOrder(HttpServletRequest request,
			HttpServletResponse response) {
		String msg = "";

		Order order = new Order();

		// 获得会员
		String strMemberId = request.getParameter("memberId");
		Member member = null;
		int memberId = 0;
		try {
			memberId = Integer.parseInt(strMemberId);
		} catch (NumberFormatException e) {
			msg = "{'success':false,'msg':'会员不可为空'}";
			WebAppUtils.ajaxResponse(response, msg);
		}
		Map<String, Object> map1 = new HashMap<String, Object>();
		List<Integer> groupIds = new ArrayList<Integer>();
		for (Group group : this.getUser(request).getGroups()) {
			groupIds.add(group.getId());
		}
		map1.put("groups", groupIds);
		map1.put("id", memberId);
		map1.put("hallcode", this.getUser(request).getOrganizationId());
		member = memberService.findById(map1);
		order.setMember(member);

		// 获得当前时间
		order.setInputTime(new Date());

		// 获得备注
		String remarks = request.getParameter("remarks");
		order.setRemarks(remarks);

		// 获得产品
		String strId = request.getParameter("productIds");
		String[] strProdutId = strId.split(",");
		int productId = 0;
		List<OrderDetail> set = new ArrayList<OrderDetail>();
		OrderDetail orderDetail = null;
		Product product = null;
		double money = 0.00;
		for (String pId : strProdutId) {
			orderDetail = new OrderDetail();
			try {
				productId = Integer.parseInt(pId);
			} catch (NumberFormatException e) {
				msg = "{'success':false,'msg':'产品格式不正确'}";
				WebAppUtils.ajaxResponse(response, msg);
			}
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("productId", productId);
			params.put("groups", groupIds);
			params.put("hallcode", this.getUser(request).getOrganizationId());
			product = this.productService.findById(params);
			orderDetail.setOrder(order);
			orderDetail.setProduct(product);
			set.add(orderDetail);
			money = NumberUtils.add(money, product.getPrice());
		}

		order.setMoney(money);

		// 计算获得积分
		Site site = systemService.getSystem();
		Double toScore = money / site.getToScore();
		int score = toScore.intValue();
		order.setScore(score);
		order.setOrderDetails(set);

		int i = this.orderService.save(order);
		if (i == 0) {
			msg = "{'success':false,'msg':'添加账单失败'}";
		} else {
			msg = "{'success':true,'msg':'添加账单成功'}";
			Order result = this.orderService.findByOrder(order);
			if (result == null) {

			} else {
				for (OrderDetail orderdetail : set) {
					orderdetail.setOrder(result);
					int j = this.orderDetailService.save(orderdetail);
					if (j <= 0) {
						msg = "{'success':false,'msg':'添加账单明细失败'}";
					}
				}
			}
		}
		WebAppUtils.ajaxResponse(response, msg);
	}

	/** 添加商品购买账单 */
	@RequestMapping(value = "/addGoodsOrder.jhtml")
	public void addGoodsOrder(HttpServletRequest request,
			HttpServletResponse response) {
		String msg = "";
		Remaining remaining = null;
		Order order = new Order();
		// 获得会员
		String strMemberId = request.getParameter("id");
		Member member = null;
		int memberId = 0;
		try {
			memberId = Integer.parseInt(strMemberId);
			remaining = remainingService.findById(memberId);
		} catch (NumberFormatException e) {
			msg = "{'success':false,'msg':'会员不可为空'}";
			WebAppUtils.ajaxResponse(response, msg);
			return;
		}
		Map<String, Object> map1 = new HashMap<String, Object>();
		List<Integer> groupIds = new ArrayList<Integer>();
		for (Group group : this.getUser(request).getGroups()) {
			groupIds.add(group.getId());
		}
		map1.put("groups", groupIds);
		map1.put("id", memberId);
		map1.put("hallcode", this.getUser(request).getOrganizationId());
		member = memberService.findById(map1);
		order.setMember(member);
		//设置支付方式默认现金
		order.setPayType(1);
		//设置购买类型
		order.setType("商品");

		// 获得当前时间
		order.setInputTime(new Date());

		// 获得备注
		String remarks = request.getParameter("remarks");
		if (remarks != null) {
			order.setRemarks(remarks);
		} else {
			order.setRemarks(member.getName() + "购买商品:");
		}

		// 获得商品
		String strCodes = request.getParameter("codes");
		String strCounts = request.getParameter("counts");
		/*
		 * String[] strGoodsCode = strCodes.split(","); String[] strGoodsCounts
		 * = strCounts.split(","); Set<GoodsOrderDetail> set = new
		 * HashSet<GoodsOrderDetail>();
		 */
		GoodsOrderDetail goodsOrderDetail = new GoodsOrderDetail();
		Goods goods = null;
		double money = 0.00;
		/*
		 * int con = 0; for (String code : strGoodsCode) { goodsOrderDetail =
		 * new GoodsOrderDetail(); goods =
		 * this.goodservive.findGoodsByCode(code);
		 * order.setRemarks(order.getRemarks() + goods.getName()); if (con + 1 <
		 * strGoodsCode.length) { order.setRemarks(order.getRemarks() + ","); }
		 * goodsOrderDetail.setOrder(order); goodsOrderDetail.setGoods(goods);
		 * goodsOrderDetail.setCounts(Integer.parseInt(strGoodsCounts[con]));
		 * set.add(goodsOrderDetail); money = NumberUtils.add(money,
		 * goods.getPrice() * goodsOrderDetail.getCounts()); con++; }
		 */

		goods = this.goodservive.findGoodsByCode(strCodes);
		order.setRemarks(order.getRemarks() + goods.getName());
		goodsOrderDetail.setOrder(order);
		goodsOrderDetail.setGoods(goods);
		goodsOrderDetail.setCounts(Integer.parseInt(strCounts));
		money = NumberUtils.add(money,
				goods.getPrice() * goodsOrderDetail.getCounts());

		Double discountPrice = Double.parseDouble(request
				.getParameter("discountPrice"));
		order.setDiscount(discountPrice);
		money = NumberUtils.sub(money, discountPrice);
		order.setMoney(money);
		int ykc = goods.getCounts();
		Double yje = 0.0;
		if (remaining != null) {
			yje = remaining.getRemaining();
			if (yje < money) {
				msg = "您的金额已不足，请及时充值!";
			} else {
				// 计算获得积分
				Site site = systemService.getSystem();
				Double toScore = money / site.getToScore();
				Integer yscore = remaining.getScore();
				int score = toScore.intValue();
				score+=yscore;
				order.setScore(score);
				// 添加订单负责人
				User user = new User();
				user.setId(request.getParameter("seller"));
				order.setSeller(user);
				if (this.orderService.save(order) > 0) {
					if (remaining != null) {
						yje -= money;
					}
					remaining.setRemaining(yje);
					remaining.setScore(score);
					// --是否修改账户余额成功
					if (!remainingService.updateRemainingById(remaining)) {
						WebAppUtils.ajaxResponse(response, "账户余额修改失败!");
						return;
					}
					if (goods != null) {
						ykc -= Integer.parseInt(strCounts);
					}
					goods.setCounts(ykc);
					if (!goodservive.update(goods)) {
						WebAppUtils.ajaxResponse(response, "商品库存修改失败!");
						return;
					}
					goodsOrderDetail.setOrder(order);
					if (this.goodsOrderDetailService.save(goodsOrderDetail) > 0) {
						msg = "购买商品成功!";
					} else {
						msg = "购买商品失败!";
					}
				} else {
					msg = "购买商品失败!";
				}
			}
		} else {
			msg = "您的金额已不足，请及时充值!";
		}
		WebAppUtils.ajaxResponse(response, msg);
	}

	@RequestMapping(value = "/searchGoodsOrder.jhtml")
	public String findGoodsOrdersByCdts(String goodsCode, String goodsName,
			String memberId, String sellerId, String goodsType,
			String resporId, String buyBeginTime, String buyEndTime,
			String searchType, String pageNo, String pageSize,
			HttpServletRequest request, HttpServletResponse response,
			ModelMap model) {
		this.initFrontHeader(request, model);
		User user = this.getUser(request);
		int start = 0;
		int limit = 10;
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isNotBlank(pageSize)) {
			limit = Integer.parseInt(pageSize);
		}
		if (StringUtils.isNotBlank(pageNo)) {
			start = (Integer.parseInt(pageNo) - 1) * limit;
		}
		if (StringUtils.isNotBlank(goodsCode)) {
			map.put("goodsCode", goodsCode);
			model.put("goodsCode", goodsCode);
		}
		if (StringUtils.isNotBlank(goodsName)) {
			map.put("goodsName", goodsName);
			model.put("goodsName", goodsName);
		}
		if (StringUtils.isNotBlank(goodsType)) {
			map.put("goodsType", goodsType);
			model.put("goodsType", goodsType);
		}
		if (StringUtils.isNotBlank(resporId)) {
			map.put("resporId", resporId);
			model.put("resporId", resporId);
		}
		if (StringUtils.isNotBlank(memberId)) {
			map.put("memberId", memberId);
			model.put("memberId", memberId);
		}
		if (StringUtils.isNotBlank(sellerId)) {
			map.put("sellerId", sellerId);
			model.put("sellerId", sellerId);
		}
		if (StringUtils.isNotBlank(buyBeginTime)) {
			map.put("buyBeginTime", buyBeginTime);
			model.put("buyBeginTime", buyBeginTime);
		}
		if (StringUtils.isNotBlank(buyEndTime)) {
			map.put("buyEndTime", buyEndTime);
			model.put("buyEndTime", buyEndTime);
		}
		map.put("searchType", searchType);

		List<Integer> groupIds = new ArrayList<Integer>();
		for (Group group : this.getUser(request).getGroups()) {
			groupIds.add(group.getId());
		}
		map.put("groups", groupIds);
		map.put("organizationid", user.getOrganizationId());
		PaginatedList<Order> orders = orderService.findGoodsOrdersByCdts(start,
				limit, map);
		model.put("orders", orders);

		// 查询商品类型
		List<GoodType> goodTypes = goodTypeService.findAll();
		model.put("types", goodTypes);
		// 查询卖出人
		List<GroupUserModel> respors = this.userService.findUsersByGroupId("4",
				user.getOrganizationId());
		model.put("respors", respors);
		// 查询会员

		Map<String, Object> map1 = new HashMap<String, Object>();
		map1.put("key", "organizationId");
		map1.put("value", user.getOrganizationId());
		map1.put("groups", groupIds);
		map1.put("hallcode", this.getUser(request).getOrganizationId());
		List<Member> members = memberService.findMemberByProperty(map1);
		model.put("members", members);

		return "goods_search";
	}

	/** 作废订单 */
	@RequestMapping(value = "disableOrder.jhtml")
	public void disableOrder(HttpServletRequest request,
			HttpServletResponse response, ModelMap model) {
		String msg = "";
		String strIds = request.getParameter("ids");
		String chaId = request.getParameter("charger");
		String Ids[] = {};

		if (StringUtils.isBlank(strIds)) {
			msg = "{'success':false, 'msg':'请选择订单！'}";
			WebAppUtils.ajaxResponse(response, msg);
			return;
		}
		
		if (StringUtils.isBlank(chaId)) {
			msg = "{'success':false, 'msg':'请选择负责人！'}";
			WebAppUtils.ajaxResponse(response, msg);
			return;
		}
		
		User user = this.userService.findById(chaId);

		Ids = strIds.split(",");
		
		for (String strId : Ids) {
			int Id = 0;
			try {
				Id = Integer.parseInt(strId);
			} catch (NumberFormatException e) {
				msg = "{'success':false, 'msg':'订单编号格式不正确！'}";
				WebAppUtils.ajaxResponse(response, msg);
				return;
			}
			Order order = this.orderService.findById(Id);
			if (order.getState() == 0 || "退款".equals(order.getType())) {
				msg = "{'success':false, 'msg':'订单已作废，请重新选择！'}";
				WebAppUtils.ajaxResponse(response, msg);
				return;
			}
		}
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("Ids", strIds);
		map.put("responseId", chaId);
		int i = this.orderService.disableOrder(map);
		if (i > 0) {
			int Id = 0;
			Order order = null;
			Order order2 = null;
			for (String strId : Ids) {
				try {
					Id = Integer.parseInt(strId);
				} catch (NumberFormatException e) {
					msg = "{'success':false, 'msg':'订单编号格式不正确！'}";
					WebAppUtils.ajaxResponse(response, msg);
					return;
				}
				order = this.orderService.findById(Id);

				order2 = new Order();

				order2.setType("退款");
				
				order2.setSeller(user);
				order2.setSellerId(chaId);
				Double acm = order.getActualMoney();
				order2.setActualMoney(acm);
				order2.setDiscount(order.getDiscount());
				order2.setInputTime(new Date());
				order2.setMember(order.getMember());
				order2.setMoney(order.getMoney());
				order2.setRemarks(order.getRemarks());
				order2.setScore(-order.getScore());
				order2.setState(1);
				order2.setPayType(1);
				
				int oi = this.orderService.save(order2);
				if (oi <= 0) {
					msg = "{'success':false, 'msg':'新建退款订单失败！'}";
					WebAppUtils.ajaxResponse(response, msg);
					return;
				}
				Remaining rem = this.remainingService.findById(order
						.getMember().getMemberid());
				acm += rem.getRemaining();
				rem.setRemaining(acm);
				//退还积分
				int sc = rem.getScore() - order.getScore();
				if (sc <= 0) sc = 0;
				rem.getScore();
				rem.setScore(sc);
				boolean b = this.remainingService.updateRemainingById(rem);
				if (b) {
					String ids = "";
					OrderDetail od2 = null;
					for (OrderDetail od : order.getOrderDetails()) {
						ProductRemaining pr = od.getProductRemaining();
						if (pr == null) {

						} else {
							ids += String.valueOf(od.getProductRemaining().getId()) + ",";
						}

						od2 = new OrderDetail();
						od2.setOrder(order2);
						od2.setProduct(od.getProduct());
						this.orderDetailService.save(od2);

						od.setProRemainId(null);
						this.orderDetailService.update(od);
					}
					if (ids == null || ids.length() <= 0) {
						msg = "{'success':true, 'msg':'订单已作废！'}";
					} else {
						ids = ids.substring(0, ids.length() - 1);
						boolean prB = this.productRemainingService.deleteByIds(ids);
						if (prB) msg = "{'success':true, 'msg':'订单已作废！'}";
						else msg = "{'success':false, 'msg':'订单作废失败！'}";
					}
				} else {
					msg = "{'success':false, 'msg':'订单作废退款失败！'}";
					WebAppUtils.ajaxResponse(response, msg);
					return;
				}
			}
		} else {
			msg = "{'success':false, 'msg':'订单作废失败！'}";
		}

		WebAppUtils.ajaxResponse(response, msg);
	}

	/** 结清 */
	@RequestMapping(value = "clearOrder.jhtml")
	public void clearOrder(HttpServletRequest request,
			HttpServletResponse response, ModelMap model) {
		String msg = "";
		String strIds = request.getParameter("ids");
		String strDiscount = request.getParameter("discount");
		String responseId = request.getParameter("responseId");
		String Ids[] = {};

		if (StringUtils.isBlank(strIds)) {
			msg = "{'success':false, 'msg':'请选择订单！'}";
			WebAppUtils.ajaxResponse(response, msg);
			return;
		}
		
		if (StringUtils.isBlank(responseId)) {
			msg = "{'success':false, 'msg':'请选择负责人！'}";
			WebAppUtils.ajaxResponse(response, msg);
			return;
		}

		User user = this.userService.findById(responseId);
		
		Ids = strIds.split(",");
		
		//判断是否已结清
		for (String strId : Ids) {
			int Id = 0;
			try {
				Id = Integer.parseInt(strId);
			} catch (NumberFormatException e) {
				msg = "{'success':false, 'msg':'订单编号格式不正确！'}";
				WebAppUtils.ajaxResponse(response, msg);
				return;
			}
			Order order = this.orderService.findById(Id);
			if (order.getState() == 0 || "退款".equals(order.getType()) || !"定金".equals(order.getType())) {
				msg = "{'success':false, 'msg':'订单不是定金类型，请重新选择！'}";
				WebAppUtils.ajaxResponse(response, msg);
				return;
			}
		}

		int Id = 0;
		Order order = null;
		Member member = null;
		Remaining rem = null;
		List<Order> listO = new ArrayList<Order>();
		Double zje = 0.0, am = 0.0, discount = 0.0, ye = 0.0, toScore = 0.0;

		try {
			discount = Double.parseDouble(strDiscount);
		} catch (NumberFormatException e1) {
			msg = "{'success':false, 'msg':'折扣格式不正确！'}";
			WebAppUtils.ajaxResponse(response, msg);
			return;
		}
		// 循环查找订单
		for (String strId : Ids) {
			try {
				Id = Integer.parseInt(strId);
			} catch (NumberFormatException e) {
				msg = "{'success':false, 'msg':'订单编号格式不正确！'}";
				WebAppUtils.ajaxResponse(response, msg);
				return;
			}
			order = this.orderService.findById(Id);
			member = order.getMember();
			if (member != null && member.getMemberid() != null) {
				rem = this.remainingService.findyje(member.getMemberid());
			}
			zje += order.getMoney();
			am += order.getActualMoney();

			// 计算获得积分
			Double money = zje - discount;
			//如果金额小于0
			if (money < 0) money = 0.00;
			Site site = systemService.getSystem();
			toScore = money / site.getToScore();
			order.setScore(toScore.intValue());

			if (rem != null) {
				Integer curScore = rem.getScore();
				if (curScore != null) {
					curScore = curScore + toScore.intValue();
					//rem.setScore(curScore + curScore);
					rem.setScore(curScore);
				}
			}
			listO.add(order);
		}
		
		//修改状态
		Status status = member.getChildStatus();
		if (status != null) {
			status = status.getParent();
			if (status != null) {
				if (!"正式会员".equals(status.getName())) {
					member.setSubstatus("0020");
				}
			} else {
				member.setSubstatus("0020");
			}
		} else {
			member.setSubstatus("0020");
		}

		ye = this.remainingService.findyje(member.getMemberid()).getRemaining();
		if (ye < zje - am - discount) {
			msg = "{'success':false, 'msg':'余额不足，请充值！'}";
		} else {
			//作废定金订单
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("Ids", strIds);
			map.put("responseId", responseId);
			int di = this.orderService.disableOrder(map);
			if (di <= 0) {
				msg = "{'success':false, 'msg':'作废定金订单失败！'}";
				WebAppUtils.ajaxResponse(response, msg);
				return;
			}
			
			this.memberService.updateMember(member);
			
			//先退款，然后再算价格
			rem.setRemaining(ye - zje + am + discount);
			boolean b = this.remainingService.updateRemainingById(rem);
			if (b) {
				zje = 0.0;
				am = 0.0;
				ye = 0.0;
				// 新生成的全额订单
				Order or = null;
				// 新生成的退款订单
				Order odT = null;
				for (Order o : listO) {
					zje += o.getMoney();
					am += o.getActualMoney();

					or = new Order();
					or.setMember(o.getMember());
					or.setMoney(o.getMoney());
					or.setScore(o.getScore());
					or.setRemarks(o.getRemarks());
					or.setInputTime(new Date());
					or.setSeller(user);
					or.setSellerId(responseId);
					or.setType("新销售");
					or.setActualMoney(zje - discount);
					or.setDiscount(discount);
					or.setState(o.getState());
					or.setScore(o.getScore());
					or.setPayType(o.getPayType());

					odT = new Order();
					odT.setMember(o.getMember());
					odT.setMoney(o.getActualMoney());
					odT.setScore(0);
					odT.setRemarks(o.getRemarks());
					odT.setInputTime(new Date());
					odT.setSeller(user);
					odT.setSellerId(responseId);
					odT.setType("退款");
					odT.setActualMoney(o.getActualMoney());
					odT.setDiscount(0.0);
					odT.setState(o.getState());
					odT.setPayType(1);

					int i = this.orderService.save(or);
					if (i > 0) {
						int k = this.orderService.save(odT);
						if (k > 0) {

						} else {
							msg = "{'success':false, 'msg':'更新结清退款失败！'}";
							WebAppUtils.ajaxResponse(response, msg);
							return;
						}
						// 获得该订单中的产品
						Product product = null;
						ProductRemaining pr = null;
						// 全额订单明细
						OrderDetail od2 = null;
						// 退款订单明细
						OrderDetail od3 = null;
						for (OrderDetail od : order.getOrderDetails()) {
							product = od.getProduct();

							// 保存ProductRemaining
							pr = new ProductRemaining();
							pr.setMember(order.getMember());
							pr.setMemberId(order.getMember().getMemberid());
							pr.setProduct(product);
							pr.setProductId(product.getProductId());
							if (product.getType() == 101) {
								pr.setCounts(product.getCounts());
							} else {
								pr.setBeginTime(product.getBeginTime());
								pr.setEndTime(product.getEndTime());
							}
							boolean b2 = this.productRemainingService
									.saveClearOrder(pr);
							if (b2) {
								od2 = new OrderDetail();
								od2.setOrder(or);
								od2.setProduct(product);
								od2.setProductRemaining(pr);
								od2.setProRemainId(pr.getId());

								od3 = new OrderDetail();
								od3.setOrder(odT);
								od3.setProduct(product);
								int j = this.orderDetailService.save(od2);
								if (j > 0) {

								} else {
									msg = "{'success':false, 'msg':'更新结清明细失败！'}";
									WebAppUtils.ajaxResponse(response, msg);
									return;
								}

								int j2 = this.orderDetailService.save(od3);
								if (j2 > 0) {

								} else {
									msg = "{'success':false, 'msg':'更新结清退款明细失败！'}";
									WebAppUtils.ajaxResponse(response, msg);
									return;
								}
							} else {
								msg = "{'success':false, 'msg':'保存会员余额失败！'}";
								WebAppUtils.ajaxResponse(response, msg);
								return;
							}
						}
					} else {
						msg = "{'success':false, 'msg':'更新订单类型失败！'}";
						WebAppUtils.ajaxResponse(response, msg);
						return;
					}
				}
				msg = "{'success':true, 'msg':'结清成功！'}";
			} else
				msg = "{'success':true, 'msg':'结清失败！'}";
		}

		WebAppUtils.ajaxResponse(response, msg);
	}

	public OrderService getOrderService() {
		return orderService;
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}

	private ProductService productService;

	public ProductService getProductService() {
		return productService;
	}

	public void setProductService(ProductService productService) {
		this.productService = productService;
	}

	private MemberService memberService;

	public MemberService getMemberService() {
		return memberService;
	}

	public void setMemberService(MemberService memberService) {
		this.memberService = memberService;
	}

	private SystemService systemService;

	public SystemService getSystemService() {
		return systemService;
	}

	public void setSystemService(SystemService systemService) {
		this.systemService = systemService;
	}

	private OrderDetailService orderDetailService;

	public OrderDetailService getOrderDetailService() {
		return orderDetailService;
	}

	public void setOrderDetailService(OrderDetailService orderDetailService) {
		this.orderDetailService = orderDetailService;
	}

	public GoodsService getGoodservive() {
		return goodservive;
	}

	public void setGoodservive(GoodsService goodservive) {
		this.goodservive = goodservive;
	}

	public GoodsOrderDetailService getGoodsOrderDetailService() {
		return goodsOrderDetailService;
	}

	public void setGoodsOrderDetailService(
			GoodsOrderDetailService goodsOrderDetailService) {
		this.goodsOrderDetailService = goodsOrderDetailService;
	}

	public MemberClazzService getMemberClazzService() {
		return memberClazzService;
	}

	public void setMemberClazzService(MemberClazzService memberClazzService) {
		this.memberClazzService = memberClazzService;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public GoodTypeService getGoodTypeService() {
		return goodTypeService;
	}

	public void setGoodTypeService(GoodTypeService goodTypeService) {
		this.goodTypeService = goodTypeService;
	}

	public RemainingService getRemainingService() {
		return remainingService;
	}

	public void setRemainingService(RemainingService remainingService) {
		this.remainingService = remainingService;
	}

	public ProductRemainingService getProductRemainingService() {
		return productRemainingService;
	}

	public void setProductRemainingService(
			ProductRemainingService productRemainingService) {
		this.productRemainingService = productRemainingService;
	}
}
